package JUC.第02章_Future;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;


public class C2_JUF函数式接口 {//函数值接口

    public static void main(String[] args) {//四大函数式接口  juf
        Function<String,Integer> function=s->{return  s.length();}; //函数型接口
        Function<String,Integer> function1=String::length; //方法引用的函数型接口
        System.out.println(function.apply("abc"));

        Predicate<String> predicate=s->{return s.isEmpty();}; //bool型接口
        Predicate<String> predicate1=String::isEmpty; //方法引用的bool型接口
        System.out.println(predicate.test("hh"));

        Consumer<String> consumer=s->{System.out.println(s);}; //消费性接口
        Consumer<String> consumer1= System.out::println; //方法引用的bool消费性接口
//        Consumer<String> consumer2= PrintStream::println; //虽然println是PrintStream类的 但是用这个System.out
        consumer.accept("傻逼");

        Supplier<String> supplier=()->{return "你猜";}; //供给型接口
        Supplier<String> supplier1=()-> "你猜";//供给型接口
        Supplier<User> supplier2= User:: new;//供给型接口
        System.out.println(supplier2.get());

    }
}
